// This programs creates displays lanes that appear to be moving
//Has its own main function for now

#include<stdlib.h>
#include<curses.h>

//Include constant when calling leval.
# define SPEED_LV1	2110
# define SPEED_LV2
# define SPEED_LV3
# define SPEED_LV4
# define SPEED_LV5

void drawLanesEasy(int laneSpeed, WINDOW *wnd);		//3 lanes
void drawLanesMedium(int laneSpeed, WINDOW *wnd);	//4 lanes
void drawLanesHard(int laneSpeed, WINDOW *wnd);		//5 lanes
	//fast laneSpeed = 10
	//fastish laneSpeed = 110	
	//Medium  laneSpeed = 11000
	//Debug speed laneSpeed = 500000

int main(void)
{
        WINDOW *wnd;	//make new window

        initscr();        // start incurses      

	wnd = newwin(0,0,0,0);		//wnd now points to, new fullscreen window
	drawLanesEasy(SPEED_LV1, wnd);		//Call whatever leval you want with the speed and window pntr
					//We will make the default speeds fixed in the future and so we will only need to pass in the increas in speed
	endwin();
}

void drawLanesEasy(int laneSpeed, WINDOW *wnd)		//draws moving lanes, speed Depends on laneSpeed varible
{

	  int   maxcol,
                maxrow,
                row=0,
                col=0,
                rowTemp;

        getmaxyx(wnd, maxrow, maxcol);		//Gets the size of the window
	col = maxcol/4.0;		//set where the first colum starts
        while(TRUE)
        {
                if (row >= maxrow)	
                {
                        row = 0;
                }

                mvprintw(row, col, "CAR");	//lane pattern
                mvprintw(row, col+8, "CAR");	//lane pattern
                mvprintw(row, col+16, "CAR");	//lane patternr
                mvprintw(row, col+24, "CAR");	//lane pattern
                refresh();
		usleep(laneSpeed+100000);		//lane speed
                mvprintw(row, col, "   ");
                mvprintw(row, col+8, "   ");
                mvprintw(row, col+16, "   ");
                mvprintw(row, col+24, "   ");
		refresh();
                row +=1;
        }

}
